package com.sqx.modules.taking.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sqx.common.utils.Result;
import com.sqx.modules.taking.entity.Game;
import com.sqx.modules.taking.entity.OrderTaking;
import com.sqx.modules.taking.service.GameService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("app/appGame")
@Api("app游戏分类")
public class AppGameController {

    private GameService gameService;

    @GetMapping("/queryGameName")
    @ApiOperation("查询首页游戏分类")
    public Result queryGameName(Long parentId) {
        return gameService.queryGameName(parentId);
    }

    @GetMapping("/queryEjGameSort")
    @ApiOperation("查询二级分类排序")
    public Result queryEjGameSort(){
        return gameService.queryEjGameSort();
    }

    @GetMapping("/selectClassifyServiceList")
    @ApiOperation("查询所有分类和部分服务")
    public Result selectClassifyServiceList(String city,String longitude,String latitude) {
        return gameService.selectClassifyServiceList(city,longitude,latitude);
    }

    @GetMapping("/selectClassifyList")
    @ApiOperation("查询所有分类")
    public Result selectClassifyList() {
        return gameService.selectClassifyList(0);
    }

    @GetMapping("/selectServiceList")
    @ApiOperation("查询服务")
    public Result selectServiceList(Integer page,Integer limit,Long id,String longitude,String latitude,Integer condition,String salesNum,String city,String by,Long userId,Boolean isRm) {
        if(BooleanUtils.isTrue(isRm)){
            return Result.success().put("data", gameService.selectRmServiceList(page,limit,longitude,latitude,condition,salesNum,by,city,userId));
        }else {
            return Result.success().put("data", gameService.selectServiceList(page,limit,id,longitude,latitude,condition,salesNum,by,city,userId));
        }
    }
}
